
package("local_json")

    set_urls(path.join(os.scriptdir(), "json.tar.xz"))
    add_versions("3.11", "8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f")


    on_install(function (package)
        local configs = {"-DJSON_BuildTests=OFF"}
        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        import("package.tools.cmake").install(package, configs)
    end)

package("local_crccpp")
    set_urls(path.join(os.scriptdir(), "CRCpp-release-1.2.0.0.tar.gz"))

    add_versions("1.2", "382d399b939207d81537a874ec4b05abc7f59772be58425a0dd048711d43db14")


    on_install(function (package)
        local configs = {}
        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        import("package.tools.cmake").install(package , configs)
    end)

package("local_libtuntap")
    set_urls(path.join(os.scriptdir(), "libtuntap.tar"))

    add_versions("1.0", "536882f700e00c89fa44b8ad52d1709fcc839a906d60630853d964ff7019f2e8")
    add_patches("1.0", path.join(os.scriptdir(), "libtuntap-win.patch"), "1f9472eb14baf3fce8dc5404ba4363f042a4986792a2197ae9972d2e9feffedf")

    add_linkorders("tuntap++" , "tuntap")
    on_install(function (package)
        local configs = {"-DENABLE_CXX=ON" , "-DBUILD_TESTING=OFF"}
        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        import("package.tools.cmake").install(package , configs)
    end)

package("local_libusb")
    set_urls(path.join(os.scriptdir(), "libusb/libusb-cmake.tar"))
    add_versions("1.0.26", "4083dc7961d74e1f64feb4d13c1d47e0a3e2e6048a3ac4266e0793467d2f3192")

    if get_config('target_os') == "linux" and is_plat("cross") then
        add_includedirs("include", "include/libusb-1.0")
    end

    if is_plat('android' , 'linux' , 'windows') then
        add_includedirs("include", path.join("include" , "libusb-1.0"))
    end

    on_install("cross" , "linux" ,"android" ,"windows" ,function (package)
        local configs = {}

        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
        table.insert(configs, "-DLIBUSB_ENABLE_UDEV=OFF")

        import("package.tools.cmake").install(package,configs)
    end)

package("local_jni")
    add_configs("JAVA_HOME", {description = "set JAVA_HOME", default = get_config("JAVA_HOME"), type = "string"})
    is_plat()
    on_fetch("local_jni")

